import { createBrowserRouter } from "react-router";
import RootLayout from "../components/layout/RootLayout";
import MyArticlesPage from "./articles";
import ArticlePage from "./articles/:id";
import ArticleEditPage from "./articles/:id/edit";
import CreateArticlePage from "./articles/new";
import DemoPage from "./demo";
import HomePage from "./home";
import LoginPage from "./login";
import RegisterPage from "./register";
import SettingPage from "./settings";
import SettingAgreementsPage from "./settings/agreements";
import SettingProfilePage from "./settings/profile";

const routes = createBrowserRouter([
  {
    path: "/",
    element: <RootLayout />,
    children: [
      { index: true, element: <HomePage /> },
      { path: "articles/new", element: <CreateArticlePage /> },
      { path: "articles/:id/edit", element: <ArticleEditPage /> },
      { path: "articles/:id", element: <ArticlePage /> },
      { path: "articles", element: <MyArticlesPage /> },
      { path: "demo", element: <DemoPage /> },
      { path: "login", element: <LoginPage /> },
      { path: "register", element: <RegisterPage /> },
      {
        path: "settings",
        element: <SettingPage />,
        children: [
          { path: "profile", element: <SettingProfilePage /> },
          { path: "agreements", element: <SettingAgreementsPage /> },
        ],
      },
    ],
  },
]);

export default routes;
